package com.demo.jvm.structure;

import com.demo.jvm.structure.constant.CONSTANT_info;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassFile {
 * u4             magic;
 * u2             minor_version;
 * u2             major_version;
 * u2             constant_pool_count;
 * cp_info        constant_pool[constant_pool_count-1];
 * u2             access_flags;
 * u2             this_class;
 * u2             super_class;
 * u2             interfaces_count;
 * u2             interfaces[interfaces_count];
 * u2             fields_count;
 * field_info     fields[fields_count];
 * u2             methods_count;
 * method_info    methods[methods_count];
 * u2             attributes_count;
 * attribute_info attributes[attributes_count];
 * }
 */
@Data
public class Clazz {
    /**
     * 魔数  0xCAFEBABE
     */
    private int magic;

    /**
     * 次版本号
     */
    private int minorVersion;

    /**
     * 主版本号
     */
    private int majorVersion;

    /**
     * 常量池数量  总数为1-constantPoolCount  0为不存在，用来代表不引用任何常量
     */
    private int constantPoolCount;

    /**
     * 常量池常量
     */
    private CONSTANT_info[] cpInfos;

    /**
     * 访问标识
     */
    private List<ClassAccessFlagsType> classAccessFlags;

    /**
     * 本类
     */
    private int thisClass;

    /**
     * 超类
     */
    private int superClass;

    /**
     * 接口数量
     */
    private int interfacesCount;
    private List<Integer> interfaces = new ArrayList<>();

    /**
     * 字段信息
     */
    private Field Field = new Field();
}
